package com.sunny.example.string;

import java.util.Scanner;

public class HJ32密码截取 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String input = scanner.nextLine();
            int len = input.length();
            int tmp = calc(len, input);
            System.out.print(tmp);
        }
    }

    private static int calc(int len, String input) {
        int result = 0;
        for (int i = 0; i < len; i++) {
            //ABA型
            int len1 = longest(input, i, i);
            //ABBA型
            int len2 = longest(input, i, i + 1);
            result = Math.max(result, len1 > len2 ? len1 : len2);

        }
        return result;
    }

    private static int longest(String input, int left, int right) {
        while (left >= 0 && right < input.length() && input.charAt(left) == input.charAt(right)) {
            left--;
            right++;
        }
        return right - left - 1;
    }
}
